home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 007 (1987-02-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 007 (1987-02-15)(Ossowski, Stefan)(DE)(PD).adf / C Compiler / lib.s < prev    next >
Text File  |  1987-03-04  |  1KB  |  61 lines

  1.     text
  2. #
  3. #    c%lmul    long signed multiply
  4. #
  5. #    multiplies two long operands on the stack and returns the
  6. #    result on the stack with no garbage.
  7. #
  8.     global    c%lmul
  9. c%lmul:
  10.     movm.l    &0xf000,-(%a7)        #save registers
  11.     mov.l    20(%a7),%d0        #get parameter 1
  12.     mov.w    %d0,%d2
  13.     mov.w    %d0,%d1
  14.     ext.l    %d1
  15.     swap    %d1
  16.     swap    %d0
  17.     sub.w    %d0,%d1
  18.     mov.w    26(%a7),%d0        #get msw of parameter 2
  19.     mov.w    %d0,%d3
  20.     ext.l    %d3
  21.     swap    %d3
  22.     sub.l    24(%a7),%d3        #subtract lsw of parameter 2
  23.     muls    %d0,%d1
  24.     muls    %d2,%d3
  25.     add.w    %d1,%d3
  26.     muls    %d2,%d0
  27.     swap    %d0
  28.     sub.w    %d3,%d0
  29.     swap    %d0
  30.     mov.l    %d0,24(%a7)
  31.     mov.l    16(%a7),20(%a7)        #move return address
  32.     movm.l    (%a7)+,&0x000f        #restore registers
  33.     add.w    &4,%a7            #adjust stack
  34.     rts
  35. #
  36. #    c%switch - execute c switch statement
  37. #
  38. #    the switch table is encoded as follows:
  39. #
  40. #        long    label1,case1
  41. #        long    label2,case2
  42. #        long    label3,case3
  43. #        ... for all cases
  44. #        long    0,defaultcase
  45. #
  46. #    the case variable is passed in d0
  47. #
  48.     global    c%switch
  49. c%switch:
  50.     mov.l    (%a7)+, %a0        #get table address
  51. c%sw1:
  52.     mov.l    (%a0)+, %a1        #get a label
  53.     mov.l    %a1, %d1        #test it for default
  54.     beq    c%sw2            #jump if default case
  55.     cmp.l    %d0,(%a0)+        #see if this case
  56.     bne    c%sw1            #next case if not
  57.     jmp    (%a1)            #jump to case
  58. c%sw2:
  59.     mov.l    (%a0), %a0        #get default address
  60.     jmp    (%a0)            #jump to default case
  61.